#include "sFontPreset.h"
#include "sGui.h"

namespace sgui
{
namespace preset
{    

void sFontPreset::load(const db::Record &file)
{
    sPreset::load(file);

    m_size = file[L"size"].GetAsFloat();
    m_color = file[L"color"].GetAsInt();
}

void sFontPreset::save(db::Record &file) const
{
    sPreset::save(file); 
    
    file[L"size"].Set(m_size);
    file[L"color"].Set(m_color);
}

engine::sEngineItem* sFontPreset::createEngineItem(engine::sEngine& engine)
{
	return engine.getFont((const res::sFontResource&)getResource(), *this);
}

void sFontPreset::clear()
{
    sPreset::clear();

    m_size = 1.0f;
    m_color = 0xFFFFFFFF;
}


#ifdef _EDITOR
void sFontPreset::exportRTTI(rtti::sInfoList& list)
{
    sPreset::exportRTTI(list);
    
	REGISTER_RTTI(L"Size", TEXT, NEW_RTTI_TEMPLATE_PARAMETER(
		INT, float, sFontPreset, this, &sFontPreset::setSize, &sFontPreset::getSize
	));
	REGISTER_RTTI(L"Color", TEXT, NEW_RTTI_TEMPLATE_PARAMETER(
		INT, Color, sFontPreset, this, &sFontPreset::setColor, &sFontPreset::getColor
	));
}

#endif

sFontPreset::sFontPreset(sGUI& gui, const std::wstring& name, const res::sFontResource& resource) :
    sPreset(gui, name, resource), 

    m_size(1.0f), 
    m_color(0xFFFFFFFF)
{
	m_font = gui.getEngine().getFont(resource, *this);
}

sFontPreset::~sFontPreset()
{
    //
}



};
};